/*
 *   Copyright (C) 2005 by Andrzej
 *   andrew_lz@poczta.fm
 *
 *
 *   kmc - KDE Media Catalog
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *			follow the penguin ;-)
 */

#ifndef _DBG_H_
#define _DBG_H_

#include <iostream>
#include <stdio.h>
#include <QtDebug>


#include "kinfo.h"

using namespace std;

int error(int code, const QString&desc = QString::null);
int syserror();
bool noerror(int code);
bool iserror();
int lasterror();
QString & errorstr();
char *dbgBacktrace();

#define _FLS(PROC)	PROC; fflush(stderr); fflush(stdout);

#define _LOG cout
#define _KMC_DEBUG DEBUG

#ifdef _KMC_DEBUG
	#define _DBG(proc)	_FLS(proc) ;
#else
	#define _DBG(proc) // _FLS(proc) ;
#endif

/** KDE debug functions **/

#ifdef __GNUC__
#define funcinfo "[" << __PRETTY_FUNCTION__ << "] "
#else
#define funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
#endif

#define lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "

#define __FINFO funcinfo
#define __FLINE lineinfo

#define _D ( qDebug()   << "DEBUG ("APP_VER"): " << __FINFO << ": "   )
#define _W ( qWarning() << "("APP_VER"): " << __FINFO << ": "   )
#define _E ( qWarning()   << "("APP_VER"): " << __FINFO << ": "   )
#define _F ( qCritical()   << "FUCKING FATAL ("APP_VER"): " << __FINFO << ": "   )

#define _TRACE _D << " BACKTRACE " << __FINFO << " " << __FLINE << dbgBacktrace();


#define ERR_OK               0
#define ERR_NULL_POINTER    -1
#define ERR_NO_MEMBER       -2
#define ERR_BAD_VALUE       -3
#define ERR_BAD_MODULE      -4
#define ERR_ACCESS          -5




#endif // _DBG_H_
